package lagou.learn.s1m4springboot.service;

import lagou.learn.s1m4springboot.entity.Article;
import lagou.learn.s1m4springboot.mapper.ArticleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 黄子濠
 * @date 2020/7/19 16:31
 */
@Service
public class ArticleService {

    @Autowired
    private ArticleRepository articleRepository;

    public Page<Article> page(Integer pageNum, Integer pageSize) {

        Pageable pageable = PageRequest.of(pageNum,pageSize);
        Page<Article> all = articleRepository.findAll(pageable);
        return all;
    }
}
